home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / network / nsclilib / ni_defin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  13.4 KB  |  315 lines  |  [TEXT/R*ch]

  1. /*
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *               National Center for Biotechnology Information
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:    ni_defin.h
  27. *
  28. * Author:       Beatty, Gish
  29. *
  30. * Version Creation Date:        1/1/92
  31. *
  32. * $Revision: 1.15 $
  33. *
  34. * File Description:
  35. *
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 5/12/92  Epstein     Converted tabs to spaces
  42. * 5/06/92  Epstein     Added conditionally-compiled option for use with the
  43. *                      "purify" tool
  44. *
  45. * ==========================================================================
  46. */
  47.  
  48. #ifndef _NI_DEFIN_
  49. #define _NI_DEFIN_
  50.  
  51. #define STDIN           0
  52. #define STDOUT          1
  53. #define STDERR          STDOUT + 1
  54.  
  55. /* if the "purify" tool is in use, it will seize the file descriptor which    */
  56. /* we had wanted; this is O.K., but the difference must be taken into account */
  57. /* here                                                                       */
  58. #ifndef _PURIFY
  59. #define STDPIPE         STDERR + 1
  60. #else
  61. #define STDPIPE         STDERR + 2
  62. #endif
  63.  
  64. #define NI_Handle       MHandle                 /* for API use */
  65. #define NI_HandPtr      MHandPtr                /* for API use */
  66. #define NI_Request      Request                 /* for API use */
  67. #define NI_ReqPtr       ReqPtr                  /* for API use */
  68.  
  69. #define ERRTEXT_BUFSIZ  256                     /* size of supplied error text buffer */
  70. #define HOSTNAME_SIZ    64
  71. #define INETADDR_SIZ    16                      /* of the form 255.255.255.255 */
  72. #define SVC_HOST_SIZ    64                      /* size of addr or name of host */
  73. #define SVC_NAME_SIZ    64                      /* size of name of service */
  74. #define RES_NAME_SIZ    64                      /* size of name of resource */
  75. #define RESTYP_NAME_SIZ 64                      /* size of type of resource */
  76. #define USERNAME_SIZ    64                      /* kerberos principle */
  77. #define GROUPNAME_SIZ   64                      /* kerberos instance */
  78. #define DOMAINNAME_SIZ  64                      /* kerberos realm */
  79. #define PASSWORD_SIZ    32                      /* must be encrypted */
  80.  
  81. #define MATCHES_ANY_TYPE  "*"                   /* string which matches any resource type */
  82.  
  83. #define NI_LAST_RESERVED_PORT   1024            /* ports above this MAY be legal */
  84.  
  85. #define NI_DEFAULT_TIMEOUT      60
  86. #define NI_SELECT_TIMEOUT       60
  87. #define NI_READ_TIMEOUT         NI_DEFAULT_TIMEOUT
  88. #define NI_WRITE_TIMEOUT        NI_DEFAULT_TIMEOUT
  89.  
  90. #define PIPE_TOKEN      "\003"
  91. #define PIPE_MSG_FMT    "%d\003%s\003"
  92.  
  93. #define READ_AIP                raip
  94. #define WRITE_AIP               waip
  95.  
  96. #define NI_DEFAULT_DOMAIN       "ncbi.nlm.nih.gov"      /* default domain */
  97. #define NI_DEFAULT_HOST         "dispatcher"            /* default host for dispatcher */
  98. #define NI_DEFAULT_SERVICE      "disp_port"             /* default name of service (port) */
  99. #define NI_DFLT_SVC_PORT        5557                    /* default port for service */
  100.  
  101. #define NI_CLIENT_PORT_LO_NAME  "ncbi_begin"            /* beginning of client port range */
  102. #define NI_DFLT_CLILO_PORT      5601                    /* default beginning of client port range */
  103. #define NI_CLIENT_PORT_HI_NAME  "ncbi_end"              /* end of client port range */
  104. #define NI_DFLT_CLIHI_PORT      32767                   /* default end of client port range */
  105.  
  106.  
  107. #if NETP_INET_WSOCK
  108. /* ** the following was extracted from <winsock.h> ** */
  109. /*
  110.  * Windows Sockets errors redefined as regular Berkeley error constants.
  111.  * These are commented out in Windows NT to avoid conflicts with errno.h.
  112.  * Use the WSA constants instead.
  113.  */
  114. #define EWOULDBLOCK             WSAEWOULDBLOCK
  115. #define EINPROGRESS             WSAEINPROGRESS
  116. #define EALREADY                WSAEALREADY
  117. #define ENOTSOCK                WSAENOTSOCK
  118. #define EDESTADDRREQ            WSAEDESTADDRREQ
  119. #define EMSGSIZE                WSAEMSGSIZE
  120. #define EPROTOTYPE              WSAEPROTOTYPE
  121. #define ENOPROTOOPT             WSAENOPROTOOPT
  122. #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
  123. #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
  124. #define EOPNOTSUPP              WSAEOPNOTSUPP
  125. #define EPFNOSUPPORT            WSAEPFNOSUPPORT
  126. #define EAFNOSUPPORT            WSAEAFNOSUPPORT
  127. #define EADDRINUSE              WSAEADDRINUSE
  128. #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
  129. #define ENETDOWN                WSAENETDOWN
  130. #define ENETUNREACH             WSAENETUNREACH
  131. #define ENETRESET               WSAENETRESET
  132. #define ECONNABORTED            WSAECONNABORTED
  133. #define ECONNRESET              WSAECONNRESET
  134. #define ENOBUFS                 WSAENOBUFS
  135. #define EISCONN                 WSAEISCONN
  136. #define ENOTCONN                WSAENOTCONN
  137. #define ESHUTDOWN               WSAESHUTDOWN
  138. #define ETOOMANYREFS            WSAETOOMANYREFS
  139. #define ETIMEDOUT               WSAETIMEDOUT
  140. #define ECONNREFUSED            WSAECONNREFUSED
  141. #define ELOOP                   WSAELOOP
  142. //#define ENAMETOOLONG            WSAENAMETOOLONG
  143. #define EHOSTDOWN               WSAEHOSTDOWN
  144. #define EHOSTUNREACH            WSAEHOSTUNREACH
  145. //#define ENOTEMPTY               WSAENOTEMPTY
  146. #define EPROCLIM                WSAEPROCLIM
  147. #define EUSERS                  WSAEUSERS
  148. #define EDQUOT                  WSAEDQUOT
  149. #define ESTALE                  WSAESTALE
  150. #define EREMOTE                 WSAEREMOTE
  151. #endif  /* NETP_INET_WSOCK */
  152.  
  153.  
  154. /* MACROS */
  155.  
  156. /* BLOCKSIG, UNBLOCKSIG, and BZERO are for dispatcher and ncbid only */
  157. #if defined(OS_UNIX_SYSV) && !defined(PROC_MIPS)
  158. /* for System V we cheat and use the caller's "mask" variable to store     */
  159. /* the signal; note that these macros won't work if dealing with more than */
  160. /* one signal                                                              */
  161. #define NI_BLOCKSIG(_sig, _mask)                { _mask = _sig; sighold(_sig); }
  162. #define NI_UNBLOCKSIG(_sig)                     sigrelse(_sig)
  163. #define NI_BZERO(buf, bufsize)                  Nlm_MemFill(buf, 0, bufsize)
  164. #else
  165. #define NI_BLOCKSIG(_sig, _mask)                _mask = sigblock(sigmask(_sig))
  166. #define NI_UNBLOCKSIG(_mask)                    sigsetmask(_mask)
  167. #define NI_BZERO(buf, bufsize)                  bzero(buf, bufsize)
  168. #endif
  169.  
  170.  
  171. #ifdef NETP_INET_NEWT
  172. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  173. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  174. #define NI_CLOSESOCKET(sok)                     close_socket(sok)
  175. #define NI_select(s, r, w, x, t)                NI_poll_select(s, r, w, x, t)
  176. #define NI_SETBLOCKING(fd)                      ioctl(fd, FIONBIO, "1")
  177. #define NI_SETNONBLOCKING(fd)                   ioctl(fd, FIONBIO, "0")
  178. #endif /* NETP_INET_NEWT */
  179.  
  180. #ifdef NETP_INET_PCNFS
  181. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  182. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  183. #define NI_CLOSESOCKET(sok)                     close(sok)
  184. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  185. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  186. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  187. #define NI_BLOCK_WITH_FUNCTION
  188. #endif /* NETP_INET_PCNFS */
  189.  
  190. /* Windows Sockets */
  191. #ifdef NETP_INET_WSOCK
  192. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  193. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  194. #define NI_CLOSESOCKET(sok)                     closesocket(sok)
  195. #define NI_select(s, r, w, x, t)                NI_poll_select(s, r, w, x, t)
  196. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  197. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  198. #define errno                                   WSAGetLastError()
  199. #define _INVALID_SOCKET_DEFINED_
  200. #define NI_BLOCK_WITH_FUNCTION
  201. #define SOCK_INDEX_ERRNO                        ((errno <= WSABASEERR || errno >= sys_nerr + WSABASEERR) ? 0 : (errno - WSABASEERR))
  202. #endif /* NETP_INET_WINSOCK */
  203.  
  204. /* TGV's Multinet TCP/IP suite for OpenVMS */
  205. #ifdef NETP_INET_TGV
  206. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  207. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  208. #define NI_CLOSESOCKET(sok)                     socket_close(sok)
  209. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  210. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  211. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  212. #define NI_BLOCK_WITH_FUNCTION
  213. #define SOCK_ERRNO                              socket_errno
  214. #endif
  215.  
  216. /* Wollongong TCP/IP suite for OpenVMS */
  217. #ifdef NETP_INET_TWG
  218. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  219. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  220. #define NI_CLOSESOCKET(sok)                     netclose(sok)
  221. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  222. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  223. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  224. #define NI_BLOCK_WITH_FUNCTION
  225. #endif
  226.  
  227. /* DEC TCP/IP for OpenVMS (UCX) */
  228. #ifdef NETP_INET_UCX
  229. #define NI_READSOCKET(rsok, rbuf, rlen)         recv(rsok, rbuf, rlen, 0)
  230. #define NI_WRITESOCKET(wsok, wbuf, wlen)        send(wsok, wbuf, wlen, 0)
  231. #define NI_CLOSESOCKET(sok)                     close(sok)
  232. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  233. #define NI_SETBLOCKING(fd)                      NI_SetBlocking (fd)
  234. #define NI_SETNONBLOCKING(fd)                   NI_SetNonBlocking (fd)
  235. #define NI_BLOCK_WITH_FUNCTION
  236. #define FD_SETSIZE                              32
  237. #define fd_set                                  int
  238. #define FD_SET(n, p)                            *(p) |= 1 << (n);
  239. #define FD_CLR(n,p)                             *(p) &= ~(1 << (n));
  240. #define FD_ISSET(n,p)                           ((*p) & (1 << (n)))
  241. #define FD_ZERO(p)                              *(p) = 0;
  242. #endif
  243.  
  244.  
  245. /* Macintosh */
  246. #ifdef OS_MAC
  247. #define NI_READSOCKET(rsok, rbuf, rlen)         read(rsok, rbuf, rlen)
  248. #define NI_WRITESOCKET(wsok, wbuf, wlen)        write(wsok, wbuf, wlen)
  249. #define NI_CLOSESOCKET(sok)                     close(sok)
  250. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  251. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY)       /* set blocking */
  252. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY)        /* set nonblocking */
  253.  
  254. /* The errno_long mechanism is used for interoperability between the           */
  255. /* network services library and the NCSA socket library, which need not have   */
  256. /* been compiled with the same integer size (2 byte vs. 4 byte)                */
  257. #define SOCK_ERRNO errno_long
  258. #endif
  259.  
  260.  
  261. #ifndef NI_READSOCKET /* for now, fall back on UNIX as default */
  262. #define NI_READSOCKET(rsok, rbuf, rlen)         read(rsok, rbuf, rlen)
  263. #define NI_WRITESOCKET(wsok, wbuf, wlen)        write(wsok, wbuf, wlen)
  264. #define NI_CLOSESOCKET(sok)                     close(sok)
  265. #define NI_select(s, r, w, x, t)                select(s, r, w, x, t)
  266.  
  267. #ifdef OS_UNIX_BSD
  268. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FNDELAY)       /* set blocking */
  269. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY)        /* set nonblocking */
  270. #else
  271. #define NI_SETBLOCKING(fd)      fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY)       /* set blocking */
  272. #define NI_SETNONBLOCKING(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY)        /* set nonblocking */
  273. #endif /* OS_UNIX_BSD */
  274.  
  275. #endif /* NI_READSOCKET */
  276.  
  277. /* MSDOS  */
  278.  
  279. #ifdef COMP_MSC
  280. #ifdef FD_SETSIZE
  281. #undef FD_SETSIZE
  282. #endif
  283. #define FD_SETSIZE      32
  284. #include <io.h>
  285.  
  286. #ifndef NETP_INET_NEWT
  287. #ifndef NETP_INET_PCNFS
  288. #ifndef NETP_INET_WSOCK
  289. /* copied from Sun version of this file 6-11-91 and modified */
  290. #define NFDBITS         32
  291. #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  292. #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  293. #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  294. #define FD_ZERO(p)      MemFill((char *)(p), '\0', sizeof(*(p)))
  295. #endif
  296. #endif
  297. #endif
  298.  
  299. #endif  /* COMP_MSC */
  300.  
  301. #ifndef SOCK_ERRNO
  302. #define SOCK_ERRNO errno
  303. #endif /* SOCK_ERRNO */
  304.  
  305. #ifndef SOCK_INDEX_ERRNO
  306. #define SOCK_INDEX_ERRNO SOCK_ERRNO
  307. #endif /* SOCK_INDEX_ERRNO */
  308.  
  309. #ifndef _INVALID_SOCKET_DEFINED_
  310. #define INVALID_SOCKET -1
  311. #endif /* INVALID_SOCKET */
  312.  
  313. #endif  /* _NI_DEFIN_ */
  314.  
  315.